<?php
$fromPage = $_GET["from_page"];
?>

<?php
require_once('../includes/init.php');
$domain = "https://www.pentalink.com";
?>
<?php
$sql = "SELECT * FROM `product_cate_first`";
$cateFirst = $db->getAll($sql);

foreach($cateFirst as &$cateItem){
    $sql = "SELECT *,if(`sort_order` > '0',1,0) AS `is_order` FROM `product_cate` WHERE `parent_id`='0' AND `is_index`='1' AND `is_del`='0' AND `bigcate_id`='1' AND `first_cate_id` = {$cateItem['id']} ORDER BY `is_order` DESC, `sort_order`;";
    $cateItemFirst = $db->getAll($sql);
    foreach($cateItemFirst as &$cateDetail){
        $sqlS = " `parent_id`='".$cateDetail['cate_id']."' AND";
        $sql = "SELECT *,if(`sort_order` > '0',1,0) AS `is_order` FROM `product_cate` WHERE {$sqlS} `is_del`='0' AND `product_num`>'0' ORDER BY `is_order` DESC, `sort_order`;";
        $cate_list_detail = $db->getAll($sql);
        $cateDetail["detail"] = $cate_list_detail;
    }
    $cateItem["list"] = $cateItemFirst;
}
?>

<div class="header_nav box">
    <div class="top_class box">
        <div class="header_nav_all box">全部分类</div>
        <div id="fenlei_block_tank">
            <div class="fenlei_block">
                <div class="headitem_fl_content_box box">
                    <div class="headitem_list_block box">
                        <?php   
                        if(!empty($cateFirst)):
                        foreach($cateFirst as $key1 => $cate1):  
                        ?>
                        <div class="move_input">
                            <a href="./product.php?cate_id=<?php echo $cate1["list"][0]["cate_id"]; ?>">
                                <div id="tankuang_content_item_<?php echo $cate1["id"] ?>" class="headitem_list_menu box" style="background-image: url(/img/<?php echo $cate1['img']<>''?$cate1['img']:'/none.jpg';?>);">
                                    <p><?php echo $cate1['name'];?></br>
                                        <span>
                                            <?php foreach($cate1["list"] as $key2 => $cate2):  ?>
                                                <?php echo $cate2['cate_name'];?>
                                            <?php endforeach;?>
                                        </span>
                                    </p>
                                </div>
                            </a>
                            
                            <div class="headitem_list_block_tankuang box  headitem_list_block_tankuang_<?php echo $cate1["id"] ?>">
                                <div class="tankuang_content">
                                    <?php   
                                    if(!empty($cate1["list"])):
                                    foreach($cate1["list"] as $key2 => $cate2):  
                                    ?>
                                        <div class="tankuang_content_item box tankuang_content_item_<?php echo $cate1["id"] ?>">
                                            <p class="box"><a href="./product.php?cate_id=<?php echo $cate2["cate_id"]; ?>"><?php echo $cate2['cate_name']; ?></a></p>
                                            <ul class="box">
                                                <?php foreach($cate2["detail"] as $key3 => $cate3):  ?>
                                                    <li><a href="./product.php?cate_id=<?php echo $cate3["cate_id"]; ?>"><?php echo $cate3['cate_name'];?></a></li>
                                                <?php endforeach;?>
                                            </ul>
                                        </div>
                                    <?php endforeach;?>
                                    <?php endif;?>

                                </div>
                            </div>
                        </div>
                        <?php endforeach;?>
                        <?php endif;?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="header_nav_box box">
        <ul>
            <li class="header_nav_li <?php if($fromPage == 'index'): ?> header_nav_li_active <?php endif;?>"><a href="./index.php">网站首页</a></li>
            <li class="header_nav_li <?php if($fromPage == 'news'): ?> header_nav_li_active <?php endif;?>"><a href="./news.php">行业资讯</a></li>
            <!-- <li class="header_nav_li"><a target="_blank" href="https://p.qiao.baidu.com/cps4/chatIndex?siteToken=fa9edd6c146a2526c2a20e5302b32e57&speedLogId=160263314181962f2_1602633141819_29294&reqParam=%7B%22from%22%3A0,%22sessionid%22%3A%22%22,%22siteId%22%3A%221050923%22,%22tid%22%3A%22-1%22,%22userId%22%3A%223244648%22,%22ttype%22%3A1,%22siteConfig%22%3A%7B%22eid%22%3A%223244648%22,%22queuing%22%3A%22%22,%22siteToken%22%3A%22fa9edd6c146a2526c2a20e5302b32e57%22,%22userId%22%3A%223244648%22,%22isGray%22%3A%22false%22,%22wsUrl%22%3A%22wss%3A%2F%2Fp.qiao.baidu.com%2Fcps4%2Fwebsocket%22,%22likeVersion%22%3A%22generic%22,%22siteId%22%3A%221050923%22,%22online%22%3A%22true%22,%22webRoot%22%3A%22%2F%2Fp.qiao.baidu.com%2Fcps4%2F%22,%22bid%22%3A%22158519076548463203%22,%22isSmallFlow%22%3A0,%22isPreonline%22%3A0,%22invited%22%3A0%7D,%22config%22%3A%7B%22themeColor%22%3A%224d74fa%22%7D%7D">计算选型</a></li> -->
            <li class="header_nav_li <?php if($fromPage == 'about'): ?> header_nav_li_active <?php endif;?>"><a href="./about.php">关于我们</a></li>
        </ul>
    </div>
</div>